<template>
  <view class="success-page">
    <!-- 顶部背景 -->
    <view class="success-header">
      <image class="header-bg" src="/static/Images/wallet/WalletToubu.png" mode="widthFix"></image>
      <view class="header-content">
        <view class="back-btn" @click="navigateBack">
          <image class="back-icon" src="/static/Images/wallet/Fanhui.png" mode="aspectFit"></image>
        </view>
        <view class="title">充值成功</view>
      </view>
    </view>
    
    <!-- 成功内容 -->
    <view class="success-content">
      <!-- 成功图标 -->
      <view class="success-icon-container">
        <image class="success-icon" src="/static/Images/wallet/Chenggong.png" mode="aspectFit"></image>
      </view>
      
      <!-- 成功信息 -->
      <view class="success-info">
        <view class="success-title">充值成功！</view>
        <view class="success-desc">已成功充值至您的账户</view>
        <view class="success-desc">充值金额：¥{{ amount }}</view>
      </view>
      
      <!-- 返回按钮 -->
      <button class="return-btn" @click="returnToWallet">返回钱包</button>
    </view>
    
    <!-- 底部指示器 -->
    <view class="bottom-indicator"></view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue';

// 充值金额
const amount = ref('0.00');

// 获取URL参数
onMounted(() => {
  const pages = getCurrentPages();
  const currentPage = pages[pages.length - 1];
  const amountParam = currentPage.options.amount;
  
  if (amountParam) {
    amount.value = amountParam;
  }
});

// 返回上一页
const navigateBack = () => {
  uni.navigateBack();
};

// 返回钱包
const returnToWallet = () => {
  // 返回钱包首页
  uni.navigateBack({
    delta: 2 // 返回两层，跳过充值页面直接回到钱包首页
  });
};
</script>

<style lang="scss">
.success-page {
  min-height: 100vh;
  background-color: #f5f5f5;
  position: relative;
}

/* 顶部背景 */
.success-header {
  position: relative;
  width: 100%;
  height: 200rpx;
}

.header-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.header-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 80rpx;
  position: relative;
}

.back-btn {
  position: absolute;
  left: 30rpx;
  width: 60rpx;
  height: 60rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-icon {
  width: 40rpx;
  height: 40rpx;
}

.title {
  color: #fff;
  font-size: 36rpx;
  font-weight: 500;
  text-align: center;
}

/* 成功内容 */
.success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 120rpx 30rpx 60rpx;
}

.success-icon-container {
  width: 160rpx;
  height: 160rpx;
  background-color: #ff4d4f;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 40rpx;
}

.success-icon {
  width: 100%;
  height: 100%;
}

.success-info {
  text-align: center;
  margin-bottom: 60rpx;
}

.success-title {
  font-size: 36rpx;
  font-weight: 500;
  color: #333;
  margin-bottom: 20rpx;
}

.success-desc {
  font-size: 28rpx;
  color: #999;
  line-height: 1.6;
  margin-bottom: 8rpx;
}

/* 返回按钮 */
.return-btn {
  width: calc(100% - 60rpx);
  height: 90rpx;
  line-height: 90rpx;
  background-color: #ff4d4f;
  color: #fff;
  font-size: 32rpx;
  font-weight: 500;
  border-radius: 45rpx;
  margin: 80rpx auto 40rpx;
  border: none;
  box-shadow: 0 4rpx 8rpx rgba(255, 77, 79, 0.2);
}

/* 底部指示器 */
.bottom-indicator {
  width: 120rpx;
  height: 8rpx;
  background-color: #ddd;
  border-radius: 4rpx;
  margin: 30rpx auto;
  position: absolute;
  bottom: 30rpx;
  left: 50%;
  transform: translateX(-50%);
}
</style>